import json
import os

def get_object_path(levels=3):
    path = os.path.abspath(__file__)
    for _ in range(levels):
        path = os.path.dirname(path)
    return path

def load_config():
    """加载配置文件"""
    config_path = get_object_path() + os.path.join('\\config', 'dify.json')
    try:
        with open(config_path, 'r', encoding='utf-8') as f:
            return json.load(f)
    except Exception as e:
        raise Exception(f"加载配置文件失败: {str(e)}")

# 加载配置
DIFY_CONFIG = load_config()

def get_assistant_config(assistant_id: str):
    """获取指定助手的配置"""
    if assistant_id not in DIFY_CONFIG['assistants']:
        raise ValueError(f"未找到助手配置: {assistant_id}")
    return DIFY_CONFIG['assistants'][assistant_id]

if __name__ == '__main__':
    get_object_path()